#include <iostream>

void solve2(int b, int a, int* solution) {
	
	int temp = 0;
	int temp2 = 1;

	for(int z=0; z<a; ++z) {
		
		if(temp != a && a%2 == 1) {
			std::cout << temp2 << " ";
			temp += 1;
		}
	}

}

void solve(int c, int r, int* solution) {
	
	int dir=1;
	int n = 1;

	for(int i=0; i<r; ++i) {
	
		for(int j=0; j<c; ++j) {
			int index = (i*c+j)+1;
			solution[index-1] = n;

			if( index%c == 0 && index/c > 0) {
				dir *= -1; //flip dir
				n += c-dir; //add columns
			} 

			n += dir;
		}
	}
}

int main(int argc, char**argv) {

	std::cout << "Harvester" << std::endl;

	int c,r;
	std::cout << "Rows: ";
	std::cin >> r;

	std::cout << "Columns: ";
	std::cin >> c; 

	int* solution;
	int area = c*r;
	solution = new int[area];

	solve(c,r,solution);

	for(int i=0; i<c*r; ++i) {
		std::cout << solution[i] << " ";	
	}

	std::cout << std::endl;

return 0;
}